package ${package.Controller};

import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.RequestMapping;
import com.dyrj.vo.PageResultMsg;
import com.dyrj.vo.ResultMsg;
import ${package.Service}.${table.serviceName};
import ${package.Entity}.${entity};
import java.util.List;

<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
<#if superControllerClassPackage??>
import ${superControllerClassPackage};
</#if>

/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("<#if package.ModuleName??>/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    @Resource
    private ${table.serviceName} service;

    @GetMapping("/index")
    @RequiresPermissions("${package.ModuleName}:${controllerMappingHyphen}:index")
    public String index(ModelMap map) {
    return "${package.ModuleName}/index_${controllerMappingHyphen}";
    }

    /**
    * @Title: table
    * @Description: (表格数据) 列表
    * @return PageInfo<${entity}>    返回类型
    */
    @GetMapping("/table")
    @ResponseBody
    @RequiresPermissions("${package.ModuleName}:${controllerMappingHyphen}:index")
    public PageResultMsg table(${entity} record) {
        return service.table(record);
    }

    /**
    * @Title: add
    * @Description: (新增)
    * @param record
    * @return ResultMsg    返回类型
    */
    @PostMapping("/")
    @ResponseBody
    @RequiresPermissions("${package.ModuleName}:${controllerMappingHyphen}:add")
    public ResultMsg add(${entity} record) {
        return service.add(record);
    }

    /**
    * @Title: info
    * @Description: (详情)
    * @param id
    * @return ${entity}    返回类型
    */
    @GetMapping("/{id}")
    @ResponseBody
    @RequiresPermissions("${package.ModuleName}:${controllerMappingHyphen}:info")
    public ${entity} info(@PathVariable String id) {
        return service.info(id);
    }

    /**
    * @Title: update
    * @Description: (更新)
    * @param record
    * @return ResultMsg    返回类型
    */
    @PutMapping("/")
    @ResponseBody
    @RequiresPermissions("${package.ModuleName}:${controllerMappingHyphen}:edit")
    public ResultMsg update(${entity} record) {
        return service.update(record);
    }

    /**
    * @Title: delete
    * @Description: (删除)
    * @param id
    * @return ResultMsg    返回类型
    */
    @DeleteMapping("/{id}")
    @ResponseBody
    @RequiresPermissions("${package.ModuleName}:${controllerMappingHyphen}:delete")
    public ResultMsg delete(@PathVariable String id) {
        return service.delete(id);
    }


}
</#if>
